package com.collect.zambia.zhiBean.zhiReceive;

import android.text.TextUtils;

import com.collect.zambia.zhiGlobal.zhiAppSettings.ZHIProjectConstants;
import com.collect.zambia.zhiUtils.StringUtil;

import java.io.Serializable;

public class ZHIRPerformanceB2Entity implements Serializable {
    private String completeFlag;
    private String bonus;
    private String remainNum;
    private float partConvertNum;

    public String getCompleteFlag() {
        return StringUtil.safeString(completeFlag);
    }

    public void setCompleteFlag(String completeFlag) {
        this.completeFlag = completeFlag;
    }

    public boolean isCompleteFlag() {
        return getCompleteFlag().equalsIgnoreCase("YES");
    }

    public String getBonus() {
        return StringUtil.safeString(bonus);
    }

    public void setBonus(String bonus) {
        this.bonus = bonus;
    }

    public String getBonusFormat() {
        return ZHIProjectConstants.RS_FLAG + StringUtil.numberTothousandFormatter(getBonus());
    }

    public String getRemainNum() {
        return StringUtil.safeString(remainNum);
    }

    public int getRemainNumInt() {
        return StringUtil.numberTothousandFormatterInt(getRemainNum());
    }

    public void setRemainNum(String remainNum) {
        this.remainNum = remainNum;
    }

    public float getPartConvertNum() {
        return partConvertNum;
    }

    public String getPartConvertNumFormat() {
        if (partConvertNum < 0.001F) {
            return "0";
        }

        String gpartcovertnum = (partConvertNum + "");
        if (TextUtils.isEmpty(gpartcovertnum)) {
            return "0";
        }

        if (gpartcovertnum.contains(".")) {
            String[] nums = gpartcovertnum.split("\\.");
            if (nums.length > 1) {
                String gleftnum = nums[0];
                String grightnum = nums[1];

                if (!TextUtils.isEmpty(grightnum)) {
                    if (grightnum.length() > 2) {
                        grightnum = grightnum.substring(0, 2);
                        if (grightnum.equalsIgnoreCase("00")) {
                            return gleftnum;
                        }

                        if(grightnum.endsWith("0")){
                            grightnum = grightnum.substring(0, 1);
                        }
                    }
                    if (grightnum.equalsIgnoreCase("0")) {
                        return gleftnum;
                    }
                    gpartcovertnum = gleftnum + "." + grightnum;

                } else {
                    gpartcovertnum = gleftnum;
                }
            }
        }

        return gpartcovertnum;
    }

    public void setPartConvertNum(float partConvertNum) {
        this.partConvertNum = partConvertNum;
    }
}
